home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ksslpkcs7.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.5 KB  |  157 lines

  1. /* This file is part of the KDE project
  2.  *
  3.  * Copyright (C) 2001-2003 George Staikos <staikos@kde.org>
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public License
  16.  * along with this library; see the file COPYING.LIB.  If not, write to
  17.  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.  * Boston, MA 02110-1301, USA.
  19.  */
  20.  
  21. #ifndef _KSSLPKCS7_H
  22. #define _KSSLPKCS7_H
  23.  
  24. #ifdef Q_WS_WIN
  25. #include "ksslconfig_win.h"
  26. #else
  27. #include "ksslconfig.h"
  28. #endif
  29.  
  30. #ifdef KSSL_HAVE_SSL
  31. #define crypt _openssl_crypt
  32. #include <openssl/pkcs7.h>
  33. #undef crypt
  34. #else
  35. class PKCS7;
  36. class X509;
  37. #endif
  38.  
  39. //#include <kopenssl.h>
  40. #include <ksslcertificate.h>
  41. #include <ksslcertchain.h>
  42.  
  43. #ifndef STACK_OF
  44. #define STACK_OF(x) void
  45. #endif
  46.  
  47. class KSSL;
  48. class KSSLPKCS7Private;
  49. class KOpenSSLProxy;
  50.  
  51. /**
  52.  * KDE PKCS#7 Certificate
  53.  *
  54.  * This class represents a PKCS#7 certificate
  55.  *
  56.  * @author George Staikos <staikos@kde.org>
  57.  * @see KSSL
  58.  * @short KDE PKCS#7 Certificate
  59.  */
  60. class KIO_EXPORT KSSLPKCS7 {
  61. friend class KSSL;
  62.  
  63. public:
  64.     /**
  65.      *  Destroy this PKCS#7 certificate
  66.      */
  67.     virtual ~KSSLPKCS7();
  68.  
  69.     /**
  70.      *  The name of this certificate.  This can be used to refer to the
  71.      *  certificate instead of passing the object itself.
  72.      *  @return the name of the certificate
  73.      */
  74.     QString name();
  75.  
  76.     /**
  77.      *  Create a KSSLPKCS7 object from a Base64 in a QString.
  78.      *  @param base64 the base64 representation of the certificate
  79.      *  @return a PKCS#7 object, or NULL on failure
  80.      */
  81.     static KSSLPKCS7* fromString(QString base64);
  82.  
  83.     /**
  84.      *  Create a KSSLPKCS7 object by reading a PKCS#7 file.
  85.      *  @param filename the filename to read the certificate from
  86.      *  @return a PKCS#7 object, or NULL on failure
  87.      */
  88.     static KSSLPKCS7* loadCertFile(QString filename);
  89.  
  90.     /**
  91.      *  Convert to a Base64 string.
  92.      *  @return the PKCS#7 object in base64 form
  93.      */
  94.     QString toString();
  95.  
  96.     /**
  97.      *  Raw set the PKCS7 object.
  98.      *  @param c the PKCS7 object
  99.      *  @internal
  100.      */
  101.     void setCert(PKCS7 *c);
  102.  
  103.     /**
  104.      *  Get the bottom level X.509 certificate.
  105.      *  @return the certificate, or NULL on failure
  106.      *  @see KSSLCertificate
  107.      */
  108.     KSSLCertificate *getCertificate();
  109.  
  110.     /**
  111.      *  Get the certificate chain.
  112.      *  @return the certificate chain
  113.      *  @see KSSLCertChain
  114.      */
  115.     KSSLCertChain *getChain();
  116.  
  117.     /**
  118.      *  Write the PKCS#7 to a file in raw mode.
  119.      *  @param filename the filename to write
  120.      *  @return true on success
  121.      */
  122.     bool toFile(QString filename);
  123.  
  124.     /**
  125.      *  Check the chain to make sure it's valid.
  126.      *  @return the result of the validation procedure
  127.      */
  128.     KSSLCertificate::KSSLValidation validate();
  129.  
  130.     /**
  131.      *  Check the chain to make sure it's valid.
  132.      *  Ignore any cached validation result.
  133.      *  @return the result of the validation
  134.      *  @see KSSLCertificate
  135.      */
  136.     KSSLCertificate::KSSLValidation revalidate();
  137.  
  138.     /**
  139.      *  Return true if the chain is valid.
  140.      */
  141.     bool isValid();
  142.  
  143. protected:
  144.     KSSLPKCS7();
  145.  
  146. private:
  147.     KSSLPKCS7Private *d;
  148.     PKCS7 *_pkcs;
  149.     KOpenSSLProxy *kossl;
  150.     KSSLCertificate *_cert;
  151.     KSSLCertChain *_chain;
  152. };
  153.  
  154.  
  155. #endif
  156.  
  157.